// ------------------------------------------------------------------------------------------------
// File   : DX9Bloom.h
// Date   : 2012-08-01
// Author : Weng xiao yi
// Descr. : 
//
// ------------------------------------------------------------------------------------------------

#ifndef OY_DX9AE_BLOOM_H
#define OY_DX9AE_BLOOM_H

#include "../DX9ShaderUtils.h"

typedef enum
{
	eDX9_AE_Bloom_Param_SceneIntensity = 0,
	eDX9_AE_Bloom_Param_GlowIntensity,
	eDX9_AE_Bloom_Param_HighlightThreshold,
	eDX9_AE_Bloom_Param_HighlightIntensity,
	eDX9_AE_Bloom_Param_BlurWidth,

	eDX9_AE_Bloom_Param_Num,

} DX9_AE_Bloom_Param;


// ------------------------------------------------------------------------------------------------
// CLASSES
// ------------------------------------------------------------------------------------------------

class DX9AE_Bloom : public DX9AfterEffect
{
public:

	DX9AE_Bloom();
	virtual ~DX9AE_Bloom();

	virtual void ReInit();
	virtual void OnDeviceLost();
	virtual void OnDeviceReset();
	virtual void Shutdown();

	virtual void Apply();

	inline virtual void  SetParam(DX9_AE_Context _eContext, ULONG _ulParam, float _fValue);
	inline virtual float GetParam(DX9_AE_Context _eContext, ULONG _ulParam);

	void		SetAllResourceNull();

	LPDIRECT3DTEXTURE9& GetDownSampleTexture() { return m_DownSampleTexture; }
	LPDIRECT3DSURFACE9& GetDownSampleSurface() { return m_DownSampleSurface; }
	LPDIRECT3DTEXTURE9& GetBlurSampleTexture() { return m_BlurSampleTexture; }
	LPDIRECT3DSURFACE9& GetBlurSampleSurface() { return m_BlurSampleSurface; }

private:

	FLOAT								m_afFactor[eDX9_AE_Bloom_Param_Num]; 



	LPDIRECT3DTEXTURE9					m_DownSampleTexture;
	LPDIRECT3DSURFACE9					m_DownSampleSurface;
	LPDIRECT3DTEXTURE9					m_BlurSampleTexture;
	LPDIRECT3DSURFACE9					m_BlurSampleSurface;

};

inline void DX9AE_Bloom::SetParam(DX9_AE_Context _eContext, ULONG _ulParam, float _fValue)
{
	switch(_eContext)
	{
	case eDX9_AE_Context_FloatParam:
		m_afFactor[_ulParam] = _fValue;
		break;
	}
}


inline float DX9AE_Bloom::GetParam(DX9_AE_Context _eContext, ULONG _ulParam)
{
	switch(_eContext)
	{
	case eDX9_AE_Context_FloatParam:
		return m_afFactor[_ulParam];
	}

	return 0.0f;
}



#endif // #ifdef OY_DX9AE_AABLOOM_H